package com.lxmes.business.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.lxmes.common.annotation.Log;
import com.lxmes.common.core.controller.BaseController;
import com.lxmes.common.core.domain.AjaxResult;
import com.lxmes.common.enums.BusinessType;
import com.lxmes.business.domain.CcStockInfo;
import com.lxmes.business.service.ICcStockInfoService;
import com.lxmes.common.utils.poi.ExcelUtil;
import com.lxmes.common.core.page.TableDataInfo;

/**
 * 库存明细Controller
 *
 * @author 张志煜
 * @date 2022-11-29
 */
@Api(tags="库存管理")
@RestController
@RequestMapping("/business/ccStockInfo")
public class CcStockInfoController extends BaseController
{
    @Autowired
    private ICcStockInfoService ccStockInfoService;

    /**
     * 查询库存明细列表
     */
    @ApiOperation(value="库存列表")
    @PreAuthorize("@ss.hasPermi('business:ccStockInfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(CcStockInfo ccStockInfo)
    {
        startPage();
        List<CcStockInfo> list = ccStockInfoService.selectCcStockInfoList(ccStockInfo);
        return getDataTable(list);
    }
    @GetMapping("/selectList")
    public TableDataInfo selectList(CcStockInfo ccStockInfo)
    {
        startPage();
        List<CcStockInfo> list = ccStockInfoService.selectCcStockInfoSelectList(ccStockInfo);
        return getDataTable(list);
    }

    @GetMapping("/mobileSmck")
    public AjaxResult getSmck(CcStockInfo ccStockInfo)
    {
        return AjaxResult.success(ccStockInfoService.selectCcStockInfoBySmCk(ccStockInfo));
    }

    /**
     * 导出库存明细列表
     */
    @PreAuthorize("@ss.hasPermi('business:ccStockInfo:export')")
    @Log(title = "库存明细", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CcStockInfo ccStockInfo)
    {
        List<CcStockInfo> list = ccStockInfoService.selectCcStockInfoList(ccStockInfo);
        ExcelUtil<CcStockInfo> util = new ExcelUtil<CcStockInfo>(CcStockInfo.class);
        util.exportExcel(response, list, "库存明细数据");
    }

    /**
     * 获取库存明细详细信息
     */

    @PreAuthorize("@ss.hasPermi('business:ccStockInfo:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(ccStockInfoService.selectCcStockInfoById(id));
    }
    /**
     * 新增库存明细
     */
    @PreAuthorize("@ss.hasPermi('business:ccStockInfo:add')")
    @Log(title = "库存明细", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CcStockInfo ccStockInfo)
    {
        return toAjax(ccStockInfoService.insertCcStockInfo(ccStockInfo));
    }

    /**
     * 修改库存明细
     */
    @PreAuthorize("@ss.hasPermi('business:ccStockInfo:edit')")
    @Log(title = "库存明细", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CcStockInfo ccStockInfo)
    {
        return toAjax(ccStockInfoService.updateCcStockInfo(ccStockInfo));
    }

    /**
     * 删除库存明细
     */
    @PreAuthorize("@ss.hasPermi('business:ccStockInfo:remove')")
    @Log(title = "库存明细", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(ccStockInfoService.deleteCcStockInfoByIds(ids));
    }
}
